package com.zy.kotlinmvplib.application

import android.annotation.SuppressLint
import android.content.Context
import android.support.multidex.MultiDex
import com.zy.kotlinbaselibrary.base.application.BaseApplication
import com.zy.kotlinbaselibrary.net.NetProvider
import com.zy.kotlinmvpapp.net.OkHttpConfig
import okhttp3.CookieJar
import okhttp3.Interceptor
import okhttp3.OkHttpClient


@SuppressLint("Registered")
class MyApplication : BaseApplication() {



    companion object {
        private var appContext: MyApplication? = null
        val instance: MyApplication
            get() = appContext!!
    }


    override fun onCreate() {
        super.onCreate()
        appContext = this
    }



    override fun registerProvider() {



        OkHttpConfig.okHttpConfig.registerProvider(object : NetProvider {
            override fun configInterceptors(): Array<Interceptor> {



                var interceptors:Array<Interceptor> = arrayOf(HeadInterceptor())

                return interceptors
            }

            override fun configHttps(builder: OkHttpClient.Builder) {
            }

            override fun configCookie(): CookieJar? {
                return null
            }

            override fun configConnectTimeoutMills(): Long {
                return 0L
            }

            override fun configReadTimeoutMills(): Long {
                return 0L
            }

            override fun configLogEnable(): Boolean {
                return true
            }

        })

    }

    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }


}
